﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace WindowsFormsApp2
{
    class DbHelper
    {
        public static string conStr = "server=.;database=Schools;uid=sa;pwd=LINYUHUI659";
        public static DataTable GetDataTable(string sql) {
            SqlConnection connection = new SqlConnection(conStr);
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
            connection.Open();
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            return dt;
        }
        public static int data(string sql) {
            SqlConnection connection = new SqlConnection(conStr);
            SqlCommand command = new SqlCommand(sql,connection);
            connection.Open();
            return command.ExecuteNonQuery();
        }

    }
}
